package felix.things.router.mqtt.server.broker.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 服务配置
 *
 * @author Felix
 * @date 2019/8/21
 */
@Data
@Component
@ConfigurationProperties(prefix = "spring.mqtt.broker")
public class BrokerProperties {

    /**
     * Broker唯一标识
     */
    private String id = "mqtt-server";
    /**
     * SSL启动的IP地址, 默认127.0.0.1
     */
    private String host = "127.0.0.1";
    /**
     * SSL端口号, 默认8883端口
     */
    private int mqttPort = 8883;
    /**
     * 是否开启集群
     */
    private boolean clusterEnabled = false;

    /**
     * WebSocket 是否启用
     */
    private boolean websocketEnabled = true;

    /**
     * WebSocket SSL端口号, 默认9993端口
     */
    private int websocketPort = 9993;

    /**
     * WebSocket Path值, 默认值 /mqtt
     */
    private String websocketPath = "/mqtt";

    /**
     * 心跳时间(秒), 默认60秒, 该值可被客户端连接时相应配置覆盖
     */
    private int keepAlive = 60;

    /**
     * 是否开启Epoll模式, 默认关闭
     */
    private boolean useEpoll = false;

    /**
     * Sokcet参数, 存放已完成三次握手请求的队列最大长度, 默认511长度
     */
    private int soBacklog = 511;

    /**
     * Socket参数, 是否开启心跳保活机制, 默认开启
     */
    private boolean soKeepAlive = true;

    /**
     * 是否启用kafka消息转发
     */
    private boolean kafkaBrokerEnabled = false;

    /**
     * 转发kafka主题
     */
    private String producerTopic = "mqtt_publish";

    /**
     * MQTT.Connect消息必须通过用户名密码验证
     */
    private boolean mqttPasswordMust = true;
}
